*HTML Tables*
HTML tables allow you to organize and display data in a structured format using rows and columns. The <table> element is used to create tables in HTML, containing various child elements for rows, headers, and data.
Basic Table Structure
A simple HTML table consists of the following elements:
<table>: Defines the table.
<tr> (Table Row): Represents a row in the table.
<th> (Table Header): Defines header cells.
<td> (Table Data): Represents data cells.
Table Rows and Cells
Each <tr> element represents a row, while <td> represents individual data cells.
Table Headers (<th>) vs Table Data (<td>)
<th> elements make text bold and center-aligned by default.
<td> elements contain regular data.
Table Borders
To add a border, use the `border` attribute or CSS
Merging Cells: `colspan` and `rowspan`
`colspan` merges columns.
`rowspan` merges rows.
Table Sections
<thead> Groups header content.
<tbody>: Groups table body.
<tfoot>: Groups footer.
Responsive Tables
Use `overflow-x: auto;` to make tables scrollable on small screens
Best Practices
Use <th> for headers.
Use `border-collapse: collapse;` for a clean look.
Use `colspan` and `rowspan` for complex structures.
Make tables responsive for smaller screens.
| Days of the Week |
| English |
Saturday |
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
| Hausa |
Asabar |
Lahadi |
Litinin |
Talata |
Laraba |
Alhamis |
Juma'a |
Can you try it?